package com.qianfeng.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qianfeng.mapper.SysModuleMapper;
import com.qianfeng.model.SysModule;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/menu")
public class MenuController {
    @Autowired(required = false)
    SysModuleMapper sysModuleMapper;
    @RequestMapping("/findAll")
    @ResponseBody
    @RequiresRoles(value = "admin")
    @Cacheable(value = "menu",key = "#page+'_'+#rows")
    public PageInfo findAll(Integer page,Integer rows){
        PageHelper.startPage(page,rows);
        return new PageInfo(sysModuleMapper.selectAll());
    }
}
